home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / sources.arc / COLDBOOT.S < prev    next >
Encoding:
Text File  |  1993-06-02  |  2.4 KB  |  119 lines

  1.  
  2. ; demonstrates the use of MSHRINK
  3. ; when a prg is loaded, it graps ALL avail. memory. this is
  4. ; appaling!
  5. ;
  6. ; How to fix?   Calc size of program code and then return unused
  7. ; portion to sys using mshrink
  8. ;
  9. ; THIS PROGRAM IS A SHELL FOR YOU TO USE!
  10.  
  11. calc_prog_size:
  12.  lea       program_end,a0        ; get addr of last stmt in prg
  13.  movea.l   4(a7),a1              ; get addr of basepage
  14.  suba.l    a1,a0                 ; get size of prog, place in a0
  15.  lea       stack ,a7             ; point a7 to this prgs stack
  16.  
  17. return_memory:
  18.  pea      (a0)                      ; put addr that holds total size on stack
  19.  pea      (a1)                      ; put addr that holds basepage addr
  20.  move.l   #$4a0000,-(sp)           ; GEMDOS funct. m_shrink
  21.  ; Note the above instr is a faster way of writing
  22.  ; move.w d0,-(sp)     d0 holds dummy word var.
  23.  ; move.w $#4a,-(sp)    function mshrink
  24.  trap     #1
  25.  lea      $c(sp),sp    ; reset stack, same as doing addq.l  #$c,sp
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. message:
  33.  pea    header
  34.  move.w   #9,-(sp)
  35.  trap     #1
  36.  addq.l   #6,sp
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. enter_supervisor:
  44.  move.l   #0,-(sp)
  45.  move.w   #$20,-(sp)
  46.  trap     #1
  47.  addq.l   #6,sp
  48.  movea.l  d0,a5             ; save stack
  49.  
  50. install_routine:
  51.  lea      $502,a0              ; fetch addr.Its addr that holds addr to
  52.                                ; goto when ALT-HELP is pressed
  53.  move.l   #code,(a0)           ; install
  54.  
  55.  
  56. enter_user_mode:
  57.  pea      (a5)
  58.  move.w   #$20,-(sp)
  59.  trap     #1
  60.  addq.l   #6,sp
  61.  
  62.  move.w    #0,-(sp)             ; terminate and stay resident!
  63.  move.l    a3,-(sp)
  64.  move.w    #$31,-(sp)
  65.  trap      #1
  66.  
  67. mainline:
  68.  
  69.  
  70. code:
  71.  
  72.  
  73.  clr.l    -(sp)       ; enter supervisor
  74.  move.w   #$20,-(sp)
  75.  trap     #1
  76.  clr.l    $420        ; set _memvalid to false
  77.  move.l   #4,a0       ; place address $4 in a0
  78.  jmp      (a0)        ; jump to it!
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  ;<your code goes here>
  91.  
  92.  
  93.  ; end it with rts
  94.  
  95. ;
  96. ; subroutines
  97. ;
  98.  
  99.  
  100.  
  101.  data
  102.   ;<strings  dc.b etc >
  103.             dc.l code
  104. header:     dc.b $d,$a,'Cold_Boot! Installed v1.002  Jeff Bilger.'
  105.             dc.b $d,$a,'Alt-Help to use',$d,$a,0
  106.  bss
  107.   ; block started by segment, all uninitalized data goes here
  108.  align        ; but make sure its on word boundary!!
  109.  
  110.              ds.l         16       ; stack = 16 longwords!
  111. stack:       ds.l         0        ; address of stack
  112. program_end: ds.l         0
  113.  end
  114.  
  115.  
  116.  
  117.  end
  118.